package com.hitqz.robot.biz.controller;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hitqz.robot.api.business.entity.CvdGuidePosEntity;
import com.hitqz.robot.api.business.dto.CvdGuidePosQueryDTO;
import com.hitqz.robot.api.business.dto.CvdGuidePosSaveDTO;
import com.hitqz.robot.api.business.dto.CvdGuidePosUpdateDTO;
import com.hitqz.robot.api.business.vo.CvdGuidePosVO;
import com.hitqz.robot.biz.service.CvdGuidePosService;
import com.hitqz.robot.common.core.util.HitConvertUtils;
import com.hitqz.robot.common.core.util.R;
import com.hitqz.robot.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

/**
 * 迎宾讲解位置
 *
 * @author kehanjiang
 * @date 2025-09-25 09:53:39
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/cvdGuidePos" )
@Tag(description = "cvdGuidePos" , name = "迎宾讲解位置管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class CvdGuidePosController {

    private final CvdGuidePosService cvdGuidePosService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param dto 迎宾讲解位置
     * @return
     */
    @Operation(summary = "分页查询" , description = "分页查询" )
    @GetMapping("/page" )
    public R<Page<CvdGuidePosVO>> getCvdGuidePosPage(@ParameterObject Page page, @ParameterObject CvdGuidePosQueryDTO dto) {
	    dto = HitConvertUtils.emptyToNull(dto);
        return R.ok(cvdGuidePosService.getCvdGuidePosPage(page, dto));
    }


    /**
     * 通过id查询迎宾讲解位置
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询" , description = "通过id查询" )
    @GetMapping("/{id}" )
    public R<CvdGuidePosVO> getById(@PathVariable("id" ) Long id) {
        return R.ok(cvdGuidePosService.getCvdGuidePosById(id));
    }

    /**
     * 新增迎宾讲解位置
     * @param dto 迎宾讲解位置
     * @return R
     */
    @Operation(summary = "新增迎宾讲解位置" , description = "新增迎宾讲解位置" )
    @SysLog("新增迎宾讲解位置" )
    @PostMapping
    public R<Boolean> save(@RequestBody CvdGuidePosSaveDTO dto) {
        return R.ok(cvdGuidePosService.saveCvdGuidePos(dto));
    }

    /**
     * 修改迎宾讲解位置
     * @param dto 迎宾讲解位置
     * @return R
     */
    @Operation(summary = "修改迎宾讲解位置" , description = "修改迎宾讲解位置" )
    @SysLog("修改迎宾讲解位置" )
    @PutMapping
    public R<Boolean> updateById(@RequestBody CvdGuidePosUpdateDTO dto) {
        return R.ok(cvdGuidePosService.updateCvdGuidePosById(dto));
    }

    /**
     * 通过id删除迎宾讲解位置
     * @param ids id列表
     * @return R
     */
    @Operation(summary = "通过id删除迎宾讲解位置" , description = "通过id删除迎宾讲解位置" )
    @SysLog("通过id删除迎宾讲解位置" )
    @DeleteMapping
    public R<Boolean> removeById(@RequestBody Long[] ids) {
        return R.ok(cvdGuidePosService.removeCvdGuidePosBatchByIds(CollUtil.toList(ids)));
    }
}